package com.focusai.efairy.ui.adapter.announce;

import android.content.Context;
import android.view.View;

import com.focusai.efairy.R;
import com.focusai.efairy.model.announce.AnnounceItem;
import com.focusai.efairy.model.project.OnItemClickEditorListener;
import com.focusai.efairy.ui.adapter.base.BaseRecyclerAdapter;
import com.focusai.efairy.ui.adapter.base.BaseRecyclerViewHolder;

/**
 * Created by luo_guangwen on 2017/9/12.
 */

public class AnnounceListAdapter extends BaseRecyclerAdapter<AnnounceItem> {

    private OnItemClickEditorListener<AnnounceItem> listener;
    private int titleColor;
    private int contentColor;
    private int timeColor;

    public AnnounceListAdapter(Context context) {
        super(context);
        this.titleColor = context.getResources().getColor(R.color.main_title2_black);
        this.contentColor = context.getResources().getColor(R.color.main_title3_black);
        this.timeColor = context.getResources().getColor(R.color.font_gray_3);
    }

    @Override
    protected int getItemLayoutId() {
        return R.layout.item_annouce_list_view;
    }

    @Override
    protected void onBindBaseRecyclerViewHolder(BaseRecyclerViewHolder holder, final int position) {
        AnnounceItem item = mList.get(position);
        if (item.efairyuserhasannouncement_is_read == AnnounceItem.IS_READ){
            holder.getImageView(R.id.iv_red_dot).setVisibility(View.GONE);
            holder.getTextView(R.id.text_title).setTextColor(timeColor);
            holder.getTextView(R.id.text_content).setTextColor(timeColor);
        }else {
            holder.getImageView(R.id.iv_red_dot).setVisibility(View.VISIBLE);
            holder.getTextView(R.id.text_title).setTextColor(titleColor);
            holder.getTextView(R.id.text_content).setTextColor(contentColor);
        }
        holder.setText(R.id.text_title, item.efairyannouncement_title);
        holder.setText(R.id.text_content, item.efairyannouncement_content);
        holder.setText(R.id.text_company_name, item.efairyannouncement_publisher_nickname);
        holder.setText(R.id.text_send_time, item.efairyannouncement_add_time);
    }

    public void setListener(OnItemClickEditorListener<AnnounceItem> listener) {
        this.listener = listener;
    }
}
